package cn.com.yusp.trace.user;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.fastjson.JSON;

import cn.com.yusp.trace.user.entity.User;

@RestController
public class UserController {
    
//    private final static Logger logger = LoggerFactory.getLogger("Application_ERROR");
    private final Logger logger = LoggerFactory.getLogger(this.getClass());

    @GetMapping("/user")
    public String selectUserFromDB() {
        logger.info("开始执行selectUserFromDB方法---------------------");
        User user = new User();
        user.setName("小红");
        user.setAge(15);
        user.setSex("男");
        logger.info("selectUserFromDB查询用户信息为："+JSON.toJSONString(user));
        try {
			//int a=10; int b=0;
			//int c = a/b;
		} catch (Exception e) {
			e.printStackTrace();
			logger.error("计算出现异常，异常信息为：",e);
		}
        
        return JSON.toJSONString(user);
    }
    
    @GetMapping("/test")
    public String test() {    
        return  "user";
    }

}